package com.ruoyi.bussiness.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.PubBuspoolStation;
import com.ruoyi.bussiness.service.IPubBuspoolStationService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 站务室Controller
 * 
 * @author ruoyi
 * @date 2023-11-12
 */
@Controller
@RequestMapping("/bussiness/poolStation")
public class PubBuspoolStationController extends BaseController
{
    private String prefix = "bussiness/poolStation";

    @Autowired
    private IPubBuspoolStationService pubBuspoolStationService;

    @RequiresPermissions("bussiness:poolStation:view")
    @GetMapping()
    public String poolStation()
    {
        return prefix + "/poolStation";
    }

    /**
     * 查询站务室列表
     */
    @RequiresPermissions("bussiness:poolStation:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(PubBuspoolStation pubBuspoolStation)
    {
        startPage();
        List<PubBuspoolStation> list = pubBuspoolStationService.selectPubBuspoolStationList(pubBuspoolStation);
        return getDataTable(list);
    }

    /**
     * 导出站务室列表
     */
    @RequiresPermissions("bussiness:poolStation:export")
    @Log(title = "站务室", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(PubBuspoolStation pubBuspoolStation)
    {
        List<PubBuspoolStation> list = pubBuspoolStationService.selectPubBuspoolStationList(pubBuspoolStation);
        ExcelUtil<PubBuspoolStation> util = new ExcelUtil<PubBuspoolStation>(PubBuspoolStation.class);
        return util.exportExcel(list, "站务室数据");
    }

    /**
     * 新增站务室
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存站务室
     */
    @RequiresPermissions("bussiness:poolStation:add")
    @Log(title = "站务室", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(PubBuspoolStation pubBuspoolStation)
    {
        return toAjax(pubBuspoolStationService.insertPubBuspoolStation(pubBuspoolStation));
    }

    /**
     * 修改站务室
     */
    @RequiresPermissions("bussiness:poolStation:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        PubBuspoolStation pubBuspoolStation = pubBuspoolStationService.selectPubBuspoolStationById(id);
        mmap.put("pubBuspoolStation", pubBuspoolStation);
        return prefix + "/edit";
    }

    /**
     * 修改保存站务室
     */
    @RequiresPermissions("bussiness:poolStation:edit")
    @Log(title = "站务室", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(PubBuspoolStation pubBuspoolStation)
    {
        return toAjax(pubBuspoolStationService.updatePubBuspoolStation(pubBuspoolStation));
    }

    /**
     * 删除站务室
     */
    @RequiresPermissions("bussiness:poolStation:remove")
    @Log(title = "站务室", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(pubBuspoolStationService.deletePubBuspoolStationByIds(ids));
    }
}
